package com.wwwarehouse.resource_center.fragment.maintenanceunit;


import android.os.Bundle;
import android.support.annotation.Nullable;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.animation.Animation;
import android.widget.GridView;

import com.wwwarehouse.common.activity.base.BaseFragment;
import com.wwwarehouse.resource_center.R;
import com.wwwarehouse.resource_center.adapter.maintenanceunit.UpdateUnitAdapter;
import com.wwwarehouse.resource_center.bean.maintenanceunit.UpdateUnitBean;

import java.util.ArrayList;
import java.util.List;

/**
 * Creator by zhenwang.xiang on 2017/10/14 11:30
 * Description: 修改单位
 */


public class UpdateUnitFragment extends BaseFragment {
    private GridView mGridView;
    private List<UpdateUnitBean> mData;
    private List<UpdateUnitBean> mItemData;
    private int mPage;

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        return inflater.inflate(R.layout.fragment_update_unit, container, false);
    }

    @Override
    public Animation onCreateAnimation(int transit, boolean enter, int nextAnim) {
        return null;
    }

    @Override
    public void onActivityCreated(@Nullable Bundle savedInstanceState) {
        super.onActivityCreated(savedInstanceState);
        initView();
        if (getArguments() != null) {
            mData = (List<UpdateUnitBean>) getArguments().getSerializable("infolist");
            mPage = getArguments().getInt("pos") - 1;
            if (mData != null) {
                for (int i = mPage * 27; i < (mPage + 1) * 27; i++) {
                    if (i >= 0 && i < mData.size()) {
                        mItemData.add(mData.get(i));
                    }
                }
                mGridView.setAdapter(new UpdateUnitAdapter(mItemData, getActivity(), mGridView));
            }
        }
    }

    private void initView() {
        mGridView = $(R.id.user_gridview);
        mData = new ArrayList<>();
        mItemData = new ArrayList<>();
    }

    @Override
    public void setTitle() {
        if (peekFragment() instanceof UpdateUnitFragment)
            mActivity.setTitle(getString(R.string.update_unit));

    }

    @Override
    public void requestDatas() {
    }
}
